package USB_Helper;

// JavaUSB.java

/**
 *
 * @author admin
 */
public class JavaUSB
{
   /**
    *  Initialize JavaUSB. Initialization succeeds if System.loadLibrary() is
    *  able to find the javausb library.
    *
    *  IMPORTANT: Call init() before calling any other method. Don't call any
    *  other method if init() returns false.
    *
    *  @return true if JavaUSB initialized; false if JavaUSB not initialized
    */

   public static boolean init ()
   {
      try
      {
          System.loadLibrary ("javausb");
          return true;
      }
      catch (UnsatisfiedLinkError e)
      { 
          return false;
      }
   }

   /**
    *  Obtain an array of all devices that are attached to the specified hub.
    *
    *  @param hubName name of the hub being interrogated
    *
    *  @return array of Devices (possibly with zero length, if no devices are
    *          attached to the hub) if successful; null if a failure occurs
    */

   public static native Device [] getAttachedDevices (String hubName);

   /**
    *  Obtain information about a specific host controller. This information
    *  consists of the host controller's name and the name of its root hub.
    *
    *  @param index zero-based index of host controller
    *
    *  @return HCInfo object containing information if successful; null if
    *          host controller does not exist
    */

   public static native HCInfo getHostControllerInfo (int index);
}
